Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MWPW-153363] Countdown Timer implementation based on page metadata #2928

Merged
merged 19 commits into from
Sep 23, 2024

Conversation

rahulgupta999
Copy link
Contributor

@rahulgupta999 rahulgupta999 commented Sep 20, 2024

As presented in AST, the regions have been using a ticker/timer/countdown visual to boost click-through rates and engagement as an enticement for certain promotions; e.g., Black Friday / Cyber Monday

image

Countdown Timer (CDT)
Properties:

Resolves: MWPW-153363

Test URLs:

Before: https://main--milo--adobecom.hlx.page/drafts/rahulgup/marquee-parent?martech=off
After: https://cdt-metatag--milo--rahulgupta999.hlx.page/drafts/rahulgup/marquee-parent?martech=off

This has the following authoring dependencies
New Placeholder texts are to be added in the placeholder file
{{cdt-ends-in}}
{{cdt-days}}
{{cdt-hours}}
{{cdt-mins}}

additionally, the following metadata should be present on the page
<meta name="countdown-timer" content="2024-08-26 12:00:00 PST,2024-09-30 00:00:00 PST">

Authoring documentation:
https://main--milo--adobecom.hlx.page/docs/authoring/promotions/countdowntimer

Copy link
Contributor

aem-code-sync bot commented Sep 20, 2024

@rahulgupta999 rahulgupta999 added run-nala Run Nala Test Automation against PR commerce new-feature New block or other feature labels Sep 20, 2024
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.27%. Comparing base (1791eb8) to head (4b93016).
Report is 2 commits behind head on stage.

Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #2928      +/-   ##
==========================================
+ Coverage   96.24%   96.27%   +0.02%     
==========================================
  Files         236      238       +2     
  Lines       54278    54515     +237     
==========================================
+ Hits        52241    52485     +244     
+ Misses       2037     2030       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rahulgupta999
Copy link
Contributor Author

I am waiting for access to promotions sheets to test this PR. For now, I have tested using injection.

@rahulgupta999 rahulgupta999 changed the title [MWPW-153363] Countdown Timer implementation based on Page Metadata [MWPW-153363] Countdown Timer implementation based on page metadata Sep 20, 2024
@rahulgupta999 rahulgupta999 added the high priority Why is this a high priority? Blocker? Critical? Dependency? label Sep 20, 2024
Copy link
Contributor

@npeltier npeltier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few nits, but most of those changes are imo required

libs/blocks/hero-marquee/hero-marquee.js Outdated Show resolved Hide resolved
libs/blocks/marquee/marquee.js Outdated Show resolved Hide resolved
libs/blocks/media/media.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
Copy link
Contributor

@npeltier npeltier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

nit, in createTag, last param can be { parent: container }, and it will be appended to container which should make you save a few lines

Copy link
Contributor

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few things 👍
Let me know what you think.

libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/blocks/marquee/marquee.js Outdated Show resolved Hide resolved
libs/blocks/hero-marquee/hero-marquee.js Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
Copy link
Contributor

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!
i took a harder look at the cdt code as well this time and found these things. Once this is all fixed up should be good from my end.

libs/blocks/marquee/marquee.js Show resolved Hide resolved
}

await Promise.all(promiseArr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, can you add a test example of a marquee with both mnemonic-list & countdown-timer to ensure this faster implementation also doesn't break anything?

function render(daysLeft, hoursLeft, minutesLeft) {
if (!isVisible) return;

removeCountdown();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why always remove the countdown ? Can you not just update the timer label?

libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
@afmicka
Copy link
Contributor

afmicka commented Sep 23, 2024

@rahulgupta999 @npeltier @yesil the countdown timer is not respecting its own start and end time when using instant parameter. Rather checks your browser time to decide whether to show the timer or not.

If you have a promo that lasts for some time (lets say 3 months) but want countdown timer to be shown only for a week inside that period, the current changes will show the timer as soon as the promo is active disregarding the defined timer starting date that comes later.

Here we have a promo that started in March this year, and timer is set to start in September. If we look at the page with the date before September with instant param, the countdown timer is still shown. The same applied for the timers end date.
https://cdt-metatag--milo--rahulgupta999.hlx.page/drafts/nala/features/promotions/promo-replace-with-countdown?instant=2024-04-22T05:00:00.000Z

Screenshot 2024-09-23 at 12 23 49

cc: @Roycethan

libs/features/cdt/cdt.js Outdated Show resolved Hide resolved
@afmicka
Copy link
Contributor

afmicka commented Sep 23, 2024

it is fixed now. The rest looks good to me. RTL is also supported.

@rahulgupta999 could you please the failing check? I will mark this PR ready for stage

@afmicka afmicka added verified PR has been E2E tested by a reviewer Ready for Stage labels Sep 23, 2024
@milo-pr-merge milo-pr-merge bot merged commit c5e352f into adobecom:stage Sep 23, 2024
14 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Sep 23, 2024
}

.horizontal .timer-block {
margin-left: 10px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about RTL support ? In RTL there's currently no space between text and timer
Screenshot 2024-09-23 at 15 20 04

libs/utils/decorate.js Show resolved Hide resolved
}

function isMobile() {
return window.matchMedia('(max-width: 767px)').matches;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value gets cached and will not work when rotating screens. You need to refactor this to always see if the viewport matches the width.
Example:

const isMobile = window.matchMedia('(max-width: 767px)');
if (isMobile.matches) doSomething(); // this will work after you resize or rotate screens.

libs/features/cdt/cdt.js Show resolved Hide resolved
libs/features/cdt/cdt.js Show resolved Hide resolved
libs/features/cdt/cdt.css Show resolved Hide resolved
@rahulgupta999 rahulgupta999 deleted the cdt-metatag branch September 23, 2024 12:56
rohitsahu pushed a commit to rohitsahu/milo that referenced this pull request Sep 27, 2024
milo-pr-merge bot pushed a commit that referenced this pull request Sep 30, 2024
* Fix RTL issues with Countdown Timer

* UT fix

* review comment

* review comment

* review comment

* font fixes

* do not reverse

* Revert "UT fix"

This reverts commit c7e4d1d.

* added CDT in notifications standard variant

* ends in vertical positioning fix

* review comments

* UT added for cdt in notification

* lint

* css fixes

* minor fix

* lint

* css

* update timer for instant query param

* narcis review feedback incorporated from PR #2928

* minor refactoring

* fix CDT alignment in media and modal block

---------

Co-authored-by: Rohit Sahu <[email protected]>
jenssingler pushed a commit to jenssingler/milo that referenced this pull request Oct 7, 2024
* Fix RTL issues with Countdown Timer

* UT fix

* review comment

* review comment

* review comment

* font fixes

* do not reverse

* Revert "UT fix"

This reverts commit c7e4d1d.

* added CDT in notifications standard variant

* ends in vertical positioning fix

* review comments

* UT added for cdt in notification

* lint

* css fixes

* minor fix

* lint

* css

* update timer for instant query param

* narcis review feedback incorporated from PR adobecom#2928

* minor refactoring

* fix CDT alignment in media and modal block

---------

Co-authored-by: Rohit Sahu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce high priority Why is this a high priority? Blocker? Critical? Dependency? new-feature New block or other feature Ready for Stage run-nala Run Nala Test Automation against PR verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants